package io.renren.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.utils.AES128Util;
import io.renren.common.utils.HttpResult;
import io.renren.common.utils.HttpUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @author lizhi
 * @Date:2019/8/13 15:13
 */
public class DemoTestCallBack {
    public static void main(String[] args) throws Exception{


        String merchantid="80000003";//商户编码
        String md5key="ef24bd940fd402f0";
        String aeskey="0C94852C65E48860";
      //  {"merchantorderid":"1582509858605","data":"","sign":"f3317f81419f4b0606c763326b727444","timestamp":"1582532576"}

        try {
            String data="SnoCvlOwVno+WXj/BCGyAn3qyiKdy6LR740OCyXa4/I6w/VUlQkzMDcV9HCKvwZaq1+E2lZ6wAd6B8MZ1z+bZzg0Nxo/+/kqOnCAF0Xz0sIyf8vzR41UwarvsubE6stqPZ8G4EMhzWrql8TSwznxsi7NpXO3yGqc4wvWTNZ8KiXRWh0DtxyTI5ZFSk0N6TPk0TsGcSpEBAw/s5CXv7FfpQ==";
            String sign="f3317f81419f4b0606c763326b727444";
            Long timestamp=1582532576L;

            String localsign=DigestUtils.md5Hex("1582509858605"+timestamp+md5key);
            System.out.println("localsign:"+localsign);
            if(!localsign.equals(sign)) {
                System.err.println("签名校验不通过");
            }
            //解开数据
            String datastr=AES128Util.decryptBase64(data, aeskey);
            System.out.println("datastr:"+datastr);
        } catch (Exception e) {
            System.err.println("参数校验出现异常");
        }
    }


}
